package com.example.androidtvdemo.demo02;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.leanback.widget.Presenter;

import com.example.androidtvdemo.R;

public class HorizontalPresenter extends Presenter {
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent) {
        View inflate = LayoutInflater.from(parent.getContext()).
                inflate(R.layout.item_hor_layout, parent, false);
        return new HorHolder(inflate);
    }

    @Override
    public void onBindViewHolder(ViewHolder viewHolder, Object item) {
        HorHolder holder = (HorHolder) viewHolder;
        if (item instanceof String) {
            holder.mTextView.setText((String) item);
        }
    }

    @Override
    public void onUnbindViewHolder(ViewHolder viewHolder) {

    }

    public static class HorHolder extends ViewHolder {

        private TextView mTextView;

        public HorHolder(View view) {
            super(view);
            mTextView = view.findViewById(R.id.tv_title);
            mTextView.setFocusableInTouchMode(true);
        }
    }
}
